#pragma once

#include<iostream>
#include"RBTree.h"
#include<vector>
namespace xiaolin
{
	template<class k,class v>
	class mymap
	{
		
		struct MkeyofT
		{
		public:
			const k& operator()(const pair<k, v>& val)
			{
				return val.first;
			}
			
		};
	public:

		typedef  typename RBTree<k, pair<const k,v>, MkeyofT>::const_iterator const_iterator;

		typedef  typename RBTree<k, pair<const k, v>, MkeyofT>::iterator iterator;

		iterator begin()
		{
			return _t.begin();
		}
		iterator end()
		{
			return _t.end();
		}
		const_iterator begin()const
		{
			return _t.begin();
		}
		const_iterator end()const
		{
			return _t.end();
		}

		v& operator[](const k& key)
		{
			pair<iterator, bool> ret = insert(make_pair(key, v()));
			return ret.first->second;
		}

		pair<iterator,bool> insert(const pair<k, v>& val)
		{
			return _t.insert(val);
		}
	private:
		RBTree<k, pair<const k, v>, MkeyofT> _t;
	};

}